package com.yundasys.springbootxa.xa.impl;

import com.yundasys.springbootxa.xa.XaService;
import com.yundasys.springbootxa.xa131.dao.Xa131Dao;
import com.yundasys.springbootxa.xa131.entity.Xa131;
import com.yundasys.springbootxa.xa132.dao.Xa132Dao;
import com.yundasys.springbootxa.xa132.entity.Xa132;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @PACKAGE_NAME: com.yundasys.springbootxa.xa.impl
 * @NAME: XaServiceImpl
 * @USER: jiangta
 * @DATE: 2021/1/11
 * @TIME: 10:22 下午
 * @PROJECT_NAME: springboot-labs
 */
@Service
public class XaServiceImpl implements XaService {

    @Resource
    private Xa131Dao xa131Dao;

    @Resource
    private Xa132Dao xa132Dao;

    @Override
    @Transactional(transactionManager = "xaTransaction")
    public void testXa() {

        Xa131 xa131 = new Xa131();
        xa131.setId(4);
        xa131.setName("xa 131");
        xa131Dao.insert(xa131);

        Xa132 xa132 = new Xa132();
        xa132.setId(4);
        //data too long error
        xa132.setName("xa 132xa 132xa 132");
        xa132Dao.insert(xa132);

    }
}
